package cn.miju.admin.biz.controller;

import cn.miju.admin.biz.service.MerchantService;
import cn.miju.admin.biz.vo.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <pre>
 * 商户管理
 * </pre>
 *
 * @author zhuming
 * @version 1.0.0
 * @since 2023-04-27 14:54
 */
@RestController
@Api(tags = "业务-商户管理")
@ApiSort(100)
@RequestMapping("/biz/merchant")
public class MerchantController {
    private final MerchantService service;

    public MerchantController(MerchantService service) {
        this.service = service;
    }

    /**
     * 商户分页查询
     * @param inVO {@link MerchantPageInVO}
     * @return {@link Page<MerchantPageOutVO>}
     */
    @ApiOperation("商户分页查询")
    @ApiOperationSupport(order = 1, author = "zhuming")
    @GetMapping("/page")
    public Page<MerchantPageOutVO> getPage(@ModelAttribute @Validated MerchantPageInVO inVO) {
        return service.getPage(inVO);
    }

    /**
     * 查询商户详情
     * @param inVO {@link MerchantDetailInVO}
     * @return {@link MerchantDetailOutVO}
     */
    @ApiOperation("查询商户详情")
    @ApiOperationSupport(order = 2, author = "zhuming")
    @GetMapping("/detail")
    public MerchantDetailOutVO getDetail(@ModelAttribute @Validated MerchantDetailInVO inVO) {
        return service.getDetail(inVO);
    }

    /**
     * 保存|修改商户信息
     * @param inVO {@link MerchantSaveInVO}
     */
    @ApiOperation("保存|修改商户信息")
    @ApiOperationSupport(order = 3, author = "zhuming")
    @PostMapping("/saveOrUpdate")
    public void saveOrUpdate(@RequestBody @Validated MerchantSaveInVO inVO) {
        service.saveOrUpdate(inVO);
    }

    /**
     * 批量删除商户
     * @param inVO {@link MerchantDeleteInVO}
     */
    @ApiOperation("批量删除商户")
    @ApiOperationSupport(order = 4, author = "zhuming")
    @PostMapping("/deletes")
    public void deletes(@RequestBody @Validated MerchantDeleteInVO inVO) {
        service.deletes(inVO);
    }

    /**
     * 修改商户状态
     * @param inVO {@link MerchantUpdateStatusInVO}
     */
    @ApiOperation("修改商户状态")
    @ApiOperationSupport(order = 5, author = "zhuming")
    @PostMapping("/updateStatus")
    public void updateStatus(@RequestBody @Validated MerchantUpdateStatusInVO inVO) {
        service.updateStatus(inVO);
    }
}
